<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-12
 * Time: 0:33
 */

namespace frontend\widget;

use yii\helpers\Url;
use yii\base\Widget;
use kartik\select2\Select2;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
use frontend\widget\RecentlyBrowserWidget;

class HeadWidget extends Widget
{
    public function run()
    {

        $homeUrl = Url::home();
        $logoSrc = \Yii::getAlias('@web/').'images/logo.png';
        $cartLink = Url::to(['shop/cart']);
        $orderList = Url::to(['order/list']);
        $addressUrl = Url::to(['address/list']);
        $searchCode = self::goodsSearch();
        $recentlyBrowser = RecentlyBrowserWidget::widget();

        return <<<HEAD
 <!-- 头部上半部分 start 包括 logo、搜索、用户中心和购物车结算 -->
    <div class="logo w1210">
        <h1 class="fl"><a href="{$homeUrl}"><img src="{$logoSrc}" alt="京西商城"></a></h1>
        <!-- 头部搜索 start -->
        {$searchCode}
        <!-- 头部搜索 end -->

        <!-- 用户中心 start-->
        <div class="user fl">
            <dl>
                <dt>
                    <em></em>
                    <a href="">用户中心</a>
                    <b></b>
                </dt>
                <dd>
                    <div class="prompt">
                        您好，请<a href="">登录</a>
                    </div>
                    <div class="uclist mt10">
                        <ul class="list1 fl">
                            <li><a href="">用户信息></a></li>
                            <li><a href="{$orderList}">我的订单></a></li>
                            <li><a href="{$addressUrl}">收货地址></a></li>
                            <li><a href="">我的收藏></a></li>
                        </ul>

                        <ul class="fl">
                            <li><a href="">我的留言></a></li>
                            <li><a href="">我的红包></a></li>
                            <li><a href="">我的评论></a></li>
                            <li><a href="">资金管理></a></li>
                        </ul>

                    </div>
                    <div style="clear:both;"></div>
                    
                </dd>
            </dl>
        </div>
        <!-- 用户中心 end-->

        <!-- 购物车 start -->
        <div class="cart fl">
            <dl>
                <dt>
                    <a href="{$cartLink}">去购物车结算</a>
                    <b></b>
                </dt>
                <dd>
                    <div class="prompt">
                        购物车中还没有商品，赶紧选购吧！
                    </div>
                </dd>
            </dl>
        </div>
        <!-- 购物车 end -->
    </div>
    <!-- 头部上半部分 end -->

HEAD;

    }

    public static function goodsSearch(){
        $searchUrl = Url::to(['shop/sphinx-search']);
        $csrftoken = \Yii::$app->request->csrftoken;
        
        $code = <<<SEARCH
        <div class="search fl">
            <div class="search_form">
                <div class="form_left fl"></div>
                <form action="{$searchUrl}" name="serarch" method="get" class="fl">
                    <input type="hidden" name="_csrf-frontend" value="{$csrftoken}" />
                    <input type="text" name="keyword" class="txt" value="请输入商品关键字" /><input type="submit" class="btn" value="search" />
                </form>
                <div class="form_right fl"></div>
            </div>

            <div style="clear:both;"></div>

            <div class="hot_search">
                <strong>热门搜索:</strong>
                <a href="">D-Link无线路由</a>
                <a href="">休闲男鞋</a>
                <a href="">TCL空调</a>
                <a href="">耐克篮球鞋</a>
            </div>
        </div>

SEARCH;
        return $code;
    }


}